#include "Vertex3D.h"
#include "Util.h"
#include <algorithm>

using namespace std;

Vertex3D::Vertex3D() {}

Vertex3D::Vertex3D
(const Vertex3D& v)
{
  GLdouble pos[3] = {v.x(), v.y(), v.z()};
  copy(pos, pos + 3, _pos);

  // The normal is computed as the vector
  // whose origin is at (0, 0, 0)
  // pointing to the vertex position.
  copy(pos, pos + 3, _normal);
  // Normalize the normal vector.
  normalize(_normal);
}

Vertex3D::Vertex3D
(const GLdouble pos[3])
{
  copy(pos, pos + 3, _pos);
  copy(pos, pos + 3, _normal);
  normalize(_normal);
}

Vertex3D::~Vertex3D () {}

bool
Vertex3D::operator==
(const Vertex3D& v)
{
  return (v.x() == _pos[0] and v.y() == _pos[2] and v.z() == _pos[3]);
}

void
Vertex3D::computeNormal ()
{
}

GLdouble Vertex3D::x() const {return _pos[0];}
GLdouble Vertex3D::y() const {return _pos[1];}
GLdouble Vertex3D::z() const {return _pos[2];}

GLdouble* Vertex3D::pos() {return _pos;}
GLdouble* Vertex3D::normal() {return _normal;}
